package main

import (
	"algorithm/ArrayList"
	"algorithm/CricleQueue"
	"algorithm/Queue"
	"algorithm/StackArray"

	"fmt"
)

func main2() {
	stack := ArrayList.NewArrayListStack()

	stack.Push("a1")
	stack.Push("b1")
	stack.Push("c1")
	stack.Push("d1")
	stack.Push("e1")

	fmt.Println(stack.Pop())
	fmt.Println(stack.Pop())
	fmt.Println(stack.Pop())
	fmt.Println(stack.Pop())

}

func main6() {

	stack := ArrayList.NewArrayListStackX()

	stack.Push("a1")
	stack.Push("b1")
	stack.Push("c1")
	stack.Push("d1")
	stack.Push("e1")

	//fmt.Println(stack.Pop())
	//fmt.Println(stack.Pop())
	//fmt.Println(stack.Pop())
	//fmt.Println(stack.Pop())

	for it := stack.Myit; it.HasNext(); {
		item, err := it.Next("b123456")
		if err != nil {
			fmt.Println("密码错误")
			break
		}
		fmt.Println(item)
	}

}

func add(num int) int {
	if num == 0 {
		return 0
	} else {
		return num + add(num-1)
	}
}

func main7() {
	fmt.Println(add(6))

	stack := StackArray.MyStack()

	stack.Push(6)
	last := 0
	for !stack.IsEmpty() {
		val := stack.Pop() //取出数字
		fmt.Println(val)
		if val == 0 {
			last += 0
		} else {
			last += val.(int)
			stack.Push((val.(int) - 1))
		}
	}
	fmt.Println(last)

}

func FAB(num int) int {
	if num == 1 || num == 2 {
		return 1
	} else {
		return FAB(num-1) + FAB(num-2)
	}

}

func main8() {
	fmt.Println(FAB(6))

	stack := StackArray.MyStack()

	last := 0
	stack.Push(6)
	for !stack.IsEmpty() {
		val := stack.Pop() //取出数字
		// fmt.Println(val)
		if val == 1 || val == 2 {
			last += 1
		} else {
			//last += val.(int)
			stack.Push((val.(int) - 1))
			stack.Push((val.(int) - 2))
		}
	}
	fmt.Println(last)

}

func main9() {
	queue := Queue.NewQueue()
	queue.EnQueue("6")
	queue.EnQueue("9")
	queue.EnQueue("10")

	fmt.Println(queue)

	fmt.Println(queue.DeQuue())
	fmt.Println(queue.DeQuue())
	fmt.Println(queue.DeQuue())
	queue.EnQueue("15")

	fmt.Println(queue.DeQuue())
	fmt.Println(queue.DeQuue())
	queue.EnQueue("16")
	fmt.Println(queue.DeQuue())
}

func main() {
	cq := CricleQueue.NewCricleQueue()

	cq.EnQueue("5")
	cq.EnQueue("6")
	cq.EnQueue("7")
	cq.EnQueue("8")
	cq.EnQueue("9")

	// cq.DelQueue("6")

	//cq.EnQueue("a")
	//cq.EnQueue("b")

	//fmt.Println(cq.DeQueue())
	//fmt.Println(cq.DeQueue())
	//fmt.Println(cq.DeQueue())

}
